package com.ebook.eboo.Service;


import com.ebook.eboo.Dao.userDAO;
import com.ebook.eboo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Service
public class userService {
    @Autowired
    userDAO userDAO;
    public List<User> getByNameAndPass(String username, String password){
        List<User> user = userDAO.getAllByUsernameAndPassword(username,password);
        return user;
    }
    public void saveUser(User user){
        userDAO.save(user);
    }
    public List<User> getAll(){
        return userDAO.getAllBy();
    }
    public User getByusername(String username){
        return userDAO.getByUsername(username);
    }
    public void deleteUser(String username){
        userDAO.deleteUserByUsername(username);
    }
    public int uodateUserById(User user){
        return userDAO.updateById(user.getUsername(),user.getPassword(),user.getType(),user.getId());
    }
}
